<?php
 //szczecin
  $lat=53.430606;
  $lng=14.556541;
  $zoom=12;
  $width=500;
  $height=500;

  //wyszukuje wszystkie stacje benzynowe uszeregowane rosnąco według lat
   $select = "SELECT points . * , cat.name AS cname, ucat.id AS id_ucat
           FROM (points LEFT JOIN cat
           ON points.id_cat = cat.id )
LEFT JOIN ucat ON cat.id_ucat = ucat.id
WHERE cat.id_ucat = 7 AND id_cat = 16
ORDER BY `points`.`lat` ASC";
 global $database;
 $database->query($select);

 
 ?>
 <div id="map" style="width: <?php echo $width; ?>px; height: <?php echo $height; ?>px">
      </div>
      <script type="text/javascript">
      //<![CDATA[

 <?php
  print("var lat=".$lat.";\n");
  print("var lng=".$lng.";\n");
  print("var zoom=".$zoom.";\n");
 
 ?>
var map;
var bounds;

initGMap();

//      function load() {
//        if (GBrowserIsCompatible()) {
//          var map = new GMap2(document.getElementById("map"));
//          map.setCenter(new GLatLng(lat, lng), zoom);
//          map.addControl(new GLargeMapControl());
//
//        }
//      }
      AddSimpleMarker(53.5461,14.80175);
      
      var polyline = new GPolyline([
         <?php
         $num_rows = mysql_num_rows($database->result);
         $i = 0;
         while ($r=$database->getResult())
{
   $i++;
   echo 'new GLatLng('.$r['lat'].', '.$r['lon'].') ';
   $s = ($i!=$num_rows)? ',' : '';
   echo $s;
}

 ?>], "#ff0000", 10);
map.addOverlay(polyline);
      //]]>
      </script>



